package com.group.three.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.group.three.mapper.PreviewVideosMapper;
import com.group.three.pojo.PreviewVideos;
import com.group.three.pojo.dto.AddNewPreviewVideoDto;
import com.group.three.service.PreviewVideosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PreviewVideosServiceImpl implements PreviewVideosService {
    @Autowired
    private PreviewVideosMapper previewVideosMapper;


    @Override
    public List<PreviewVideos> selectPreviewVideosAll() {
        return previewVideosMapper.selectPreviewVideosAll();
    }

    @Override
    public int deletePreviewId(Long previewId) {
        return previewVideosMapper.deletePreviewId(previewId);
    }

    @Override
    public List<PreviewVideos> searchByInput(String input) {
        return previewVideosMapper.searchByInput(input);
    }

    @Override
    public List<PreviewVideos> selectAll(int page,int size) {
        PageHelper.startPage(page,size);
        return previewVideosMapper.selectAll(page,size);
    }

    @Override
    public boolean AddNewPreviewVideo(AddNewPreviewVideoDto addNewPreviewVideoDto) {
        int i = previewVideosMapper.AddNewPreviewVideo(addNewPreviewVideoDto);
        if (i!=0){
            return  true;
        }else {
            return false;
        }
    }
}
